<?php

namespace App\Http\Middleware;
use Illuminate\Routing\Route;

use Closure;

class FrontLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next )
    {
        session_start();
        if(isset($_SESSION["loginUser"])){
            view()->share("loginUser",$_SESSION['loginUser']);//view调用是工厂方法 所以只能赋值 不能从模板中取数据 详情看代码
        }

        return  $next($request);
    }
}
